package com.ruoyi.web.controller.student;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.teacher.domain.Teacher;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.student.domain.BblClass;
import com.ruoyi.student.service.IBblClassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班级Controller
 * 
 * @author ruoyi
 * @date 2023-05-18
 */
@RestController
@RequestMapping("/student/class")
public class BblClassController extends BaseController
{
    @Autowired
    private IBblClassService bblClassService;

    /**
     * 查询班级列表
     */
    @PreAuthorize("@ss.hasPermi('student:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(BblClass bblClass)
    {
        startPage();
        List<BblClass> list = bblClassService.selectBblClassList(bblClass);
        return getDataTable(list);
    }

    /**
     * 查询所有班级
     */
    @PreAuthorize("@ss.hasPermi('student:class:findall')")
    @GetMapping("/findall")
    public List<BblClass> findall()
    {
        List<BblClass> list = bblClassService.findall();
        return list;
    }

    /**
     * 导出班级列表
     */
    @PreAuthorize("@ss.hasPermi('student:class:export')")
    @Log(title = "班级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BblClass bblClass)
    {
        List<BblClass> list = bblClassService.selectBblClassList(bblClass);
        ExcelUtil<BblClass> util = new ExcelUtil<BblClass>(BblClass.class);
        util.exportExcel(response, list, "班级数据");
    }

    /**
     * 获取班级详细信息
     */
    @PreAuthorize("@ss.hasPermi('student:class:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bblClassService.selectBblClassById(id));
    }

    /**
     * 新增班级
     */
    @PreAuthorize("@ss.hasPermi('student:class:add')")
    @Log(title = "班级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BblClass bblClass)
    {
        return toAjax(bblClassService.insertBblClass(bblClass));
    }

    /**
     * 修改班级
     */
    @PreAuthorize("@ss.hasPermi('student:class:edit')")
    @Log(title = "班级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BblClass bblClass)
    {
        return toAjax(bblClassService.updateBblClass(bblClass));
    }

    /**
     * 删除班级
     */
    @PreAuthorize("@ss.hasPermi('student:class:remove')")
    @Log(title = "班级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bblClassService.deleteBblClassByIds(ids));
    }


    /**
     * 查询技术老师列表
     */
    @PreAuthorize("@ss.hasPermi('student:class:getType1')")
    @GetMapping("/getType1")
    public TableDataInfo getType1()
    {
        List<Teacher> type1 = bblClassService.getType1();
        return getDataTable(type1);

    }
    /**
     * 查询班主任列表
     */
    @PreAuthorize("@ss.hasPermi('student:class:getType2')")
    @GetMapping("/getType2")
    public TableDataInfo getType2()
    {
        List<Teacher> list = bblClassService.getType2();
        return getDataTable(list);

    }

    /**
     * 查询就业老师列表
     */
    @PreAuthorize("@ss.hasPermi('student:class:getType3')")
    @GetMapping("/getType3")
    public TableDataInfo getType3()
    {
        List<Teacher> list = bblClassService.getType3();
        return getDataTable(list);

    }
}
